package com.product.shop.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.product.shop.entity.MiaoshaOrderEntity;
import com.product.shop.service.MiaoshaOrderService;
import com.product.common.utils.PageUtils;
import com.product.common.utils.R;



/**
 * 
 *
 * @author brh
 * @email sunlightcs@gmail.com
 * @date 2022-02-22 16:30:11
 */
@RestController
@RequestMapping("shop/miaoshaorder")
public class MiaoshaOrderController {
    @Autowired
    private MiaoshaOrderService miaoshaOrderService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = miaoshaOrderService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		MiaoshaOrderEntity miaoshaOrder = miaoshaOrderService.getById(id);

        return R.ok().put("miaoshaOrder", miaoshaOrder);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody MiaoshaOrderEntity miaoshaOrder){
		miaoshaOrderService.save(miaoshaOrder);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody MiaoshaOrderEntity miaoshaOrder){
		miaoshaOrderService.updateById(miaoshaOrder);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		miaoshaOrderService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
